import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:my_app/router/plugin_router.dart';

const TextStyle btnts = TextStyle(fontSize: 16);

class PluginDemoPage extends StatelessWidget {
  const PluginDemoPage({super.key});


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Plugin Demo")),
      body: Container(
        width: MediaQuery.of(context).size.width,
        height: double.infinity,
        color: const Color(0xFFEEEEEE),
        padding: const EdgeInsets.symmetric(horizontal: 16.0),
        child: SingleChildScrollView(
          child: Column(
            // 这是让按钮铺满的关键
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.openApp.path),
                child: const Text("拉起其它app", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.tableAndLaunchUrl.path),
                child: const Text("表格和launchUrl", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.flutterPicker.path),
                child: const Text("flutter_picker的Example", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.calendardatepicker2.path),
                child: const Text("日历组件calendardatepicker2的Example", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.easyloading.path),
                child: const Text("easyloading的Example", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.loggerAndWidgetsize.path),
                child: const Text("logger组件的Example和获取Widget尺寸", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.packageInfoPlus.path),
                child: const Text("package-info-plus的Example", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.deviceInfoPlus.path),
                child: const Text("device-info-plus的Example", style: btnts,)
              ),
              ElevatedButton(
                onPressed: () => _onTapBtn(context, PluginRouters.urlLauncher.path),
                child: const Text("url-launcher的Example", style: btnts,)
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _onTapBtn(BuildContext context, path) {
    context.push(path);
  }
}